<head>
    <meta charset="UTF-8">
<title>算法训练 The Great Julya Calendar</title>
<link rel="stylesheet" href="../css/main.css">
</head>
 <p>【问题描述】</p>
<p class="MsoNormal"><span style="font-size:12.0pt;font-family:宋体;mso-ascii-font-family:
Consolas;mso-hansi-font-family:Consolas">又一个世界末日正在到来！这回的元凶是</span><span lang="EN-US" style="font-size:12.0pt;font-family:Consolas">Julya</span><span style="font-size:12.0pt;font-family:宋体;mso-ascii-font-family:Consolas;
mso-hansi-font-family:Consolas">部落日历。</span><span lang="EN-US" style="font-size:
12.0pt;font-family:Consolas"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:12.0pt;font-family:宋体;mso-ascii-font-family:
Consolas;mso-hansi-font-family:Consolas">这个部落的海狸非常了解数学。</span><span lang="EN-US" style="font-size:12.0pt;font-family:Consolas">Smart Beaver</span><span style="font-size:12.0pt;font-family:宋体;mso-ascii-font-family:Consolas;
mso-hansi-font-family:Consolas">，一个考古学家，得到了一个上面有着魔法数字的神圣板块。从老海狸那得到了这样的翻译：</span><span lang="EN-US" style="font-size:12.0pt;font-family:Consolas"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:12.0pt;font-family:宋体;mso-ascii-font-family:
Consolas;mso-hansi-font-family:Consolas">愿</span><span lang="EN-US" style="font-size:12.0pt;font-family:Consolas">Great Beaver</span><span style="font-size:12.0pt;font-family:宋体;mso-ascii-font-family:Consolas;
mso-hansi-font-family:Consolas">保佑你们！愿你们的第三只眼永不会对真理视而不见！取走魔法数字，从中减去一个数字（这个数字必须在魔法数字的数位中出现过）并得到一个新的魔法数字。重复这个操作直到一个魔法数字等于</span><span lang="EN-US" style="font-size:12.0pt;font-family:Consolas">0</span><span style="font-size:12.0pt;font-family:宋体;mso-ascii-font-family:Consolas;
mso-hansi-font-family:Consolas">。地球将会站在</span><span lang="EN-US" style="font-size:12.0pt;font-family:Consolas">Three Beavers</span><span style="font-size:12.0pt;font-family:宋体;mso-ascii-font-family:Consolas;
mso-hansi-font-family:Consolas">上，时间等同于你执行的减法次数。</span><span lang="EN-US" style="font-size:12.0pt;font-family:Consolas"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:12.0pt;font-family:宋体;mso-ascii-font-family:
Consolas;mso-hansi-font-family:Consolas">不同的减法序列显然能得到不同的操作数。但是</span><span lang="EN-US" style="font-size:12.0pt;font-family:Consolas">Smart Beaver</span><span style="font-size:12.0pt;font-family:宋体;mso-ascii-font-family:Consolas;
mso-hansi-font-family:Consolas">已经做好最坏的打算并且让你计算最少他需要的操作数来把魔法数字减至</span><span lang="EN-US" style="font-size:12.0pt;font-family:Consolas">0</span><span style="font-size:12.0pt;font-family:宋体;mso-ascii-font-family:Consolas;
mso-hansi-font-family:Consolas">。</span><span lang="EN-US" style="font-size:12.0pt;
font-family:Consolas"><o:p></o:p></span></p>
<p>【输入格式】</p>
<p class="MsoNormal"><span style="font-size:12.0pt;font-family:宋体;mso-ascii-font-family:
Consolas;mso-hansi-font-family:Consolas">一行包含魔法数字</span><span lang="EN-US" style="font-size:12.0pt;font-family:Consolas">n (0&lt;=n&lt;=10^18)<o:p></o:p></span></p>
<p>【输出格式】</p>
<p class="MsoNormal"><span style="font-size:12.0pt;font-family:宋体;mso-ascii-font-family:
Consolas;mso-hansi-font-family:Consolas">输出一个整数&mdash;&mdash;把给定的魔法数字减至</span><span lang="EN-US" style="font-size:12.0pt;font-family:Consolas">0</span><span style="font-size:12.0pt;font-family:宋体;mso-ascii-font-family:Consolas;
mso-hansi-font-family:Consolas">所需最少操作数。</span><span lang="EN-US" style="font-size:12.0pt;font-family:Consolas"><o:p></o:p></span></p>
<p>【样例输入】<br />
24<br />
【样例输出】<br />
5<br />
【数据规模和约定】<br />
<span style="font-family: Consolas; font-size: 16px;">0&lt;=n&lt;=10^18</span></p>